/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.commands;

import java.util.ArrayList;
import java.util.List;
import org.jfonia.model.ISequence;
import org.jfonia.model.elements.MusicalElement;

/**
 *
 * @author Rik Bauwens
 */
public class AddMusicalElementListCommand extends Command
{
        private ISequence sequence;
        private int tick;
        private List<MusicalElement> musicalElements;

        public AddMusicalElementListCommand(ISequence sequence, int tick,
                                            List<MusicalElement> musicalElements)
        {
                super();
                this.sequence = sequence;
                this.tick = tick;
                this.musicalElements = new ArrayList<MusicalElement>(musicalElements.size());
                this.musicalElements.addAll(musicalElements);
        }

        @Override
        protected void execute()
        {
                for(MusicalElement musicalElement : musicalElements)
                        sequence.insertMusicalElement(tick, musicalElement);
        }

        @Override
        protected void undo()
        {
                for(MusicalElement musicalElement : musicalElements)
                        sequence.removeMusicalElement(musicalElement);
        }
}